package com.javasm.controller.goods;


import com.javasm.common.http.AxiosResult;
import com.javasm.common.valid.addGroup;
import com.javasm.controller.base.BaseController;
import com.javasm.domin.entity.goods.GiftsToGoodsInfo;
import com.javasm.domin.entity.goods.GoodsToGifts;
import com.javasm.domin.entity.goods.GoodsToGiftsInfo;
import com.javasm.service.goods.IGiftsToGoodsInfoService;
import com.javasm.service.goods.IGoodsToGiftsInfoService;
import com.javasm.service.goods.IGoodsToGiftsService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whl
 * @since 2022-01-16
 */
@RestController
@RequestMapping("goods-to-gifts-info")
@RequiredArgsConstructor
public class GoodsToGiftsInfoController extends BaseController {

    private final IGoodsToGiftsInfoService iGoodsToGiftsInfoService;

    /**
     * 添加
     */
    @PostMapping
    public AxiosResult<Void> add(@Validated(addGroup.class) @RequestBody GoodsToGiftsInfo goodsToGiftsInfo  ) {

        return toAxios(iGoodsToGiftsInfoService.save(goodsToGiftsInfo));
    }


    /**
     * 根据id查询
     */
    @GetMapping("{id}")
    public AxiosResult<GoodsToGiftsInfo> findById(@PathVariable Long id) {
        GoodsToGiftsInfo byId = iGoodsToGiftsInfoService.getById(id);
        return AxiosResult.success(byId);
    }
}
